package com.xiaozhu.common.video.viewholder;

import android.view.View;
import android.view.ViewGroup;

import com.xiaozhu.common.R;
import com.xiaozhu.library.adapters.BaseRecyclerViewHolder;
import com.xiaozhu.video.ListVideoPlayerController;
import com.xiaozhu.video.VideoPlayer;

/**
 * @说明
 * @作者 LY
 * @时间 2017/12/20 17:26
 * @邮箱 2743569843@qq.com
 * @版权 Copyright(c) 2017 LY-版权所有
 * @备注
 */
public class VideoViewHolder extends BaseRecyclerViewHolder {
    private ListVideoPlayerController listVideoPlayerController;
    public VideoPlayer videoPlayer;

    public VideoViewHolder(View itemView, int viewType) {
        super(itemView, viewType);
        videoPlayer = (VideoPlayer) itemView.findViewById(R.id.videoPlay);
        ViewGroup.LayoutParams params = videoPlayer.getLayoutParams();
        params.width = itemView.getResources().getDisplayMetrics().widthPixels; // 宽度为屏幕宽度
        params.height = (int) (params.width * 9f / 16f);    // 高度为宽度的9/16
        videoPlayer.setLayoutParams(params);
    }

    public void setController(ListVideoPlayerController listVideoPlayerController) {
        this.listVideoPlayerController = listVideoPlayerController;
        videoPlayer.setController(listVideoPlayerController);
    }

    public void bindData() {
        listVideoPlayerController.setTitle("测试播放");
        listVideoPlayerController.setLength(117000);
        videoPlayer.setUp("http://play.g3proxy.lecloud.com/vod/v2/MjUxLzE2LzgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTExMDc2NDEzODctYXZjLTE5OTgxOS1hYWMtNDgwMDAtNTI2MTEwLTE3MDg3NjEzLWY1OGY2YzM1NjkwZTA2ZGFmYjg2MTVlYzc5MjEyZjU4LTE0OTg1NTc2ODY4MjMubXA0?b=259&mmsid=65565355&tm=1499247143&key=f0eadb4f30c404d49ff8ebad673d3742&platid=3&splatid=345&playid=0&tss=no&vtype=21&cvid=2026135183914&payff=0&pip=08cc52f8b09acd3eff8bf31688ddeced&format=0&sign=mb&dname=mobile&expect=1&tag=mobile&xformat=super", null);
    }
}
